package com.example.lenovo.lockscreenview.LockScreenView03;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.example.lenovo.lockscreenview.R;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author zhangliwen
 * @date 2020/11/26.
 * description：
 */
public class LockScreenActivity3 extends AppCompatActivity implements View.OnClickListener {

    private static final String TAG = "MainActivity";

    public static final String LOCK = "lock";
    public static final String LOCK_KEY = "lock_key";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view3);

        SharedPreferences preferences = getSharedPreferences(LOCK, MODE_PRIVATE);

        String lockPattenString = preferences.getString(LOCK_KEY, null);

        if (lockPattenString != null) {
            Intent intent = new Intent(this, LockActivity.class);
            startActivity(intent);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.lock:
                Intent intent = new Intent(this, LockSetupActivity.class);
                startActivity(intent);
                break;
            case R.id.unlock:
                getSharedPreferences(LOCK, MODE_PRIVATE).edit().clear().commit();
                break;
            default:
                break;
        }
    }
}
